<div>
<#-- 修改密码模态框 -->
    <div class="modal fade" id="changePasswordModal" tabindex="-1" role="dialog" aria-labelledby="changePasswordModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="changePasswordModalLabel">修改密码</h4>
                </div>

                <form class="form-horizontal"  method="post" id="changePasswordForm" action="/passwordManagement/update.do">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-3 control-label">原密码：</label>
                        <div class="col-sm-6">
                            <input type="password" class="form-control"  name="oldPassword"
                                   placeholder="请输入原密码">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-3 control-label">新密码：</label>
                        <div class="col-sm-6">
                            <input type="password" class="form-control"  name="newPassword"
                                   placeholder="请输入新密码">
                        </div>
                    </div>
                </form>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button id="btn-changePassword" type="button" class="btn btn-primary">确定修改</button>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        // 修改密码
        $('#changePassword').click(function () {
            // 清空模态框
            $("#changePasswordForm input").val('');
            // 点击时弹出模态框
            $('#changePasswordModal').modal('show');
        });
        $('#btn-changePassword').click(function () {
            //点击提交按钮
            //ajaxSubmit方法可以把表单转为异步的表单，马上提交
            $('#changePasswordForm').ajaxSubmit(function (data) {
                if(data.success){
                    $.messager.alert("操作成功","2s后自动关闭")
                    window.setTimeout(function () {
                        window.location.href="/logout.do";
                    },2000)
                }else{
                    $.messager.popup(data.msg)
                }
            });
        })
    })
</script>

